Skip to content

fix(api): encode interpolated path segments in API client - #1218

Open
geoffg-sentry wants to merge 3 commits into
mainfrom
geoffg-sentry/harden-profileId
Open

fix(api): encode interpolated path segments in API client#1218
geoffg-sentry wants to merge 3 commits into
mainfrom
geoffg-sentry/harden-profileId

Conversation

@geoffg-sentry

@geoffg-sentry geoffg-sentry commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Resource IDs were interpolated into upstream REST paths unencoded, and fetch resolves ../ dot segments during URL parsing. Hardening this.

  • Added an apiPath tagged template and converted all 76 request paths in client.ts to use it. It percent-encodes each interpolated value so it cannot introduce new path segments, and rejects a value that is entirely a dot segment: encoding cannot neutralize those, because the URL spec treats .. and its percent-encoded spellings alike. Redundant manual encodeURIComponent calls were removed to avoid double-encoding.

  • Added a shared validateResourceId refinement to the affected ID parameters (eventId, attachmentId, replayId, profileId, keyId) so callers get a validation error instead of a confusing upstream 404. Also applied the existing validateSlugOrId to projectSlugOrId on the two profile tools, which had skipped it.

  • Added a test that fails on any future request path built without apiPath. The previous fix for this class hardened the parameters vulnerable at the time and left the IDs raw, so enforcing the invariant matters more than enumerating parameters.

  • Corrected docs/specs/subpath-constraints.md, which incorrectly stated that clients can override the injected org/project per call.

  • added .pnpm-store/ to .gitignore mostly so I don't make a mistake later

Shouldn't break a thing. Encoding is a no-op for any legitimate slug character set.

Comment thread packages/mcp-core/src/api-client/api-path.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e358764. Configure here.

@geoffg-sentry
geoffg-sentry force-pushed the geoffg-sentry/harden-profileId branch from e358764 to a463489 Compare July 31, 2026 13:37
@getsentry getsentry deleted a comment from cursor Bot Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants